home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume16 / vex.v2r2 / patch3 < prev    next >
Encoding:
Text File  |  1992-03-05  |  11.8 KB  |  468 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!think.com!mips!msi!dcmartin
  3. From: "David C. Carver" <dcc@Athena.MIT.EDU>
  4. Subject: v16i109: vex.v2r2 patch #3, Patch3, Part01/01
  5. Message-ID: <1992Mar5.215838.9953@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-16i109-vex.v2r2@uunet.UU.NET>
  10. Date: Thu, 5 Mar 1992 21:58:38 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: "David C. Carver" <dcc@Athena.MIT.EDU>
  14. Posting-number: Volume 16, Issue 109
  15. Archive-name: vex.v2r2/patch3
  16. Patch-To: vex.v2r2: Volume 16, Issue 52
  17.  
  18.                 Xv2r2 Patch #3
  19.  
  20. This patch:
  21.  
  22. This patch adds a program called eset to
  23.  
  24.     
  25.     mit/extensions/xv/test
  26.  
  27. and modifies the corresponding Imakefile to build it.  The program eset
  28. allows users to query and set a port's encoding attribute.
  29.  
  30. To apply this patch:
  31.  
  32. cd to the top of the source tree (to the directory containing the "mit"
  33. and "contrib" subdirectories) and do:
  34.  
  35.         patch -p -s < ThisFile
  36.  
  37. Patch will work silently unless an error occurs.  You will likely get
  38. two warning messages, which can be ignored:
  39.  
  40.         mkdir: mit: File exists
  41.  
  42. If you want to watch patch do its thing, leave out the "-s" argument to patch.
  43.  
  44. After applying this patch:
  45.  
  46. You need to cd to mit/extensions/xv/test and say
  47.  
  48.     make Makefile
  49.     make
  50.  
  51. Prereq: xv-patch-level-2
  52.  
  53. *** /tmp/XVPATCHLEVEL.1    Mon Mar  2 11:03:18 1992
  54. --- mit/XVPATCHLEVEL    Mon Mar  2 11:04:37 1992
  55. ***************
  56. *** 2 ****
  57. ! VERSION xv-patch-level-2
  58. --- 2 ----
  59. ! VERSION xv-patch-level-3
  60.  
  61. *** mit/extensions/xv/test/Imakefile.0    Thu Dec 12 12:01:18 1991
  62. --- mit/extensions/xv/test/Imakefile    Mon Mar  2 11:26:59 1992
  63. ***************
  64. *** 31,42 ****
  65.      XVT8SRCS = xvt8.c
  66.      XVT8OBJS = xvt8.o
  67.   
  68.          SRCS = $(XVT1SRCS) $(XVT2SRCS) $(XVT3SRCS) $(XVT4SRCS) $(XVT5SRCS) \
  69. !     $(XVT6SRCS) $(XVT7SRCS) $(XVT8SRCS) $(XVT9SRCS) $(XVT10SRCS)
  70.          OBJS = $(XVT1OBJS) $(XVT2OBJS) $(XVT3OBJS) $(XVT4OBJS) $(XVT5OBJS) \
  71. !     $(XVT6OBJS) $(XVT7OBJS) $(XVT8OBJS) $(XVT9OBJS) $(XVT10OBJS)
  72.   
  73. ! all:: xvt1 xvt2 xvt3 xvt4 xvt5 xvt6 xvt7 xvt8
  74.   
  75.   SingleProgramTarget(xvt1, $(XVT1OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
  76.   SingleProgramTarget(xvt2, $(XVT2OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
  77. --- 31,45 ----
  78.      XVT8SRCS = xvt8.c
  79.      XVT8OBJS = xvt8.o
  80.   
  81. +    ESETSRCS = eset.c
  82. +    ESETOBJS = eset.o
  83.          SRCS = $(XVT1SRCS) $(XVT2SRCS) $(XVT3SRCS) $(XVT4SRCS) $(XVT5SRCS) \
  84. !     $(XVT6SRCS) $(XVT7SRCS) $(XVT8SRCS) $(ESETSRCS) $(XVT10SRCS)
  85.          OBJS = $(XVT1OBJS) $(XVT2OBJS) $(XVT3OBJS) $(XVT4OBJS) $(XVT5OBJS) \
  86. !     $(XVT6OBJS) $(XVT7OBJS) $(XVT8OBJS) $(ESETOBJS) $(XVT10OBJS)
  87.   
  88. ! all:: xvt1 xvt2 xvt3 xvt4 xvt5 xvt6 xvt7 xvt8 eset
  89.   
  90.   SingleProgramTarget(xvt1, $(XVT1OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
  91.   SingleProgramTarget(xvt2, $(XVT2OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
  92. ***************
  93. *** 46,51 ****
  94. --- 49,55 ----
  95.   SingleProgramTarget(xvt6, $(XVT6OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
  96.   SingleProgramTarget(xvt7, $(XVT7OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
  97.   SingleProgramTarget(xvt8, $(XVT8OBJS), $(XVLIBPATH), -lXv -lXext -lX11)
  98. + SingleProgramTarget(eset, $(ESETOBJS), $(XVLIBPATH), -lXv -lXext -lX11)
  99.   
  100.   xvt1: $(XVT1LIBS)
  101.   xvt2: $(XVT2LIBS)
  102. ***************
  103. *** 55,59 ****
  104. --- 59,64 ----
  105.   xvt6: $(XVT6LIBS)
  106.   xvt7: $(XVT7LIBS)
  107.   xvt8: $(XVT8LIBS)
  108. + eset: $(ESETLIBS)
  109.   
  110.   DependTarget()
  111.  
  112. *** mit/extensions/xv/test/eset.c.0    Mon Mar  2 10:19:49 1992
  113. --- mit/extensions/xv/test/eset.c    Mon Mar  2 09:48:07 1992
  114. ***************
  115. *** 0 ****
  116. --- 1,344 ----
  117. + /***********************************************************
  118. + Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
  119. + and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  120. +                         All Rights Reserved
  121. + Permission to use, copy, modify, and distribute this software and its 
  122. + documentation for any purpose and without fee is hereby granted, 
  123. + provided that the above copyright notice appear in all copies and that
  124. + both that copyright notice and this permission notice appear in 
  125. + supporting documentation, and that the names of Digital or MIT not be
  126. + used in advertising or publicity pertaining to distribution of the
  127. + software without specific, written prior permission.  
  128. + DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  129. + ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  130. + DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  131. + ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  132. + WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  133. + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  134. + SOFTWARE.
  135. + ******************************************************************/
  136. + /*
  137. + ** File: 
  138. + **
  139. + **   eset.c --- Xv test program to set encoding
  140. + **   
  141. + ** Author: 
  142. + **
  143. + **   David Carver (Digital Workstation Engineering/Project Athena)
  144. + **
  145. + ** Revisions:
  146. + **
  147. + **   26.02.92 Carver
  148. + **     - first version
  149. + **       
  150. + */
  151. + #include <stdio.h>
  152. + #include <X11/Xlib.h>
  153. + #include <X11/Xutil.h>
  154. + #include <X11/extensions/Xvlib.h>
  155. + main(argc, argv)
  156. +      int         argc;
  157. +      char        *argv[];
  158. + {
  159. +   char chr;
  160. +   int ii, jj, kk, ll, status, mask, nitems;
  161. +   unsigned int actual_w, actual_h;
  162. +   int screen;
  163. +   Display *dpy;
  164. +   Visual *vis,*def_vis;
  165. +   XVisualInfo *p_vis_info, vis_info_temp;
  166. +   XGCValues gc_attr;
  167. +   GC gc;
  168. +   XSetWindowAttributes win_attr;
  169. +   Window root,main_win;
  170. +   Colormap def_cmap;
  171. +   XEvent event;
  172. +   unsigned long version, revision;
  173. +   unsigned long nAdaptors, nEncodings;
  174. +   XvAdaptorInfo *pAdaptors, *pAdaptor;
  175. +   XvEncodingInfo *pEncoding, *pEncodings;
  176. +   XvPortID port;
  177. +   XvEncodingID encoding, old_encoding;
  178. +   XvEvent *pe;
  179. +   float rate;
  180. +   Atom encoding_atom;
  181. +   char *encoding_name;
  182. +   unsigned long vis_id;
  183. +   unsigned long depth;
  184. +   unsigned int evb, erb, mop;
  185. +   dpy = XOpenDisplay(0);
  186. +   if (!dpy)
  187. +     {
  188. +       printf("\n  Couldn't open display\n");
  189. +       printf("\n  eset terminated\n");
  190. +       exit();
  191. +     }
  192. +   screen = XDefaultScreen(dpy);
  193. +   def_vis = XDefaultVisual(dpy, screen);
  194. +   def_cmap = XDefaultColormap(dpy, screen);
  195. +   root = XDefaultRootWindow(dpy);
  196. +   status = XvQueryExtension(dpy, &version, &revision, &mop, &evb, &erb);
  197. +   if (status != Success)
  198. +     {
  199. +       printf("\n  The Xv Extension is not installed.\n");
  200. +       printf("\n  eset terminated\n");
  201. +       exit();
  202. +     }
  203. +   printf("\n  Xv V%01d.%d\n", version, revision);
  204. +   XvQueryAdaptors(dpy, root, &nAdaptors, &pAdaptors);
  205. +   if (!nAdaptors)
  206. +     {
  207. +       printf("\n  Your display has no video adaptors.\n");
  208. +       printf("\n  eset terminated\n");
  209. +       exit();
  210. +     }
  211. +   if (!Setup(argc, argv, nAdaptors, pAdaptors, 
  212. +         &port, &depth, &vis_id))
  213. +     {
  214. +       printf("\n  Setup failed.\n");
  215. +       printf("\n  eset terminated\n");
  216. +       exit();
  217. +     }
  218. +   
  219. +   XvQueryEncodings(dpy, port, &nEncodings, &pEncodings);
  220. +   
  221. +   encoding_atom = XInternAtom(dpy,"XV_ENCODING",False);
  222. +   XvGetPortAttribute(dpy, port, 
  223. +              encoding_atom, (int *)&encoding);
  224. +   pEncoding = pEncodings;
  225. +   for (jj=0; jj<nEncodings; jj++)
  226. +     {
  227. +       if (encoding == pEncoding->encoding_id)
  228. +     {
  229. +       printf("\n");
  230. +       printf("  Current port encoding is `%s'\n", pEncoding->name);
  231. +     }
  232. +       pEncoding++;
  233. +     }
  234. +   printf("\n");
  235. +   printf("  The encodings supported by this adaptor are:\n");
  236. +   printf("\n");
  237. +   pEncoding = pEncodings;
  238. +   for (jj=0; jj<nEncodings; jj++)
  239. +     {
  240. +       printf("  %2d: %s\n", pEncoding->encoding_id, pEncoding->name);
  241. +       pEncoding++;
  242. +     }
  243. +   for (;;)
  244. +     {
  245. +       printf("\n");
  246. +       printf("Select encoding number: ");
  247. +       scanf("%d",&encoding);
  248. +       
  249. +       pEncoding = pEncodings;
  250. +       for (jj=0; jj<nEncodings; jj++)
  251. +     {
  252. +       
  253. +       if (encoding == pEncoding->encoding_id)
  254. +         {
  255. +           encoding_name = pEncoding->name;
  256. +           break;
  257. +         }
  258. +       pEncoding++;
  259. +     }
  260. +       
  261. +       if (jj <= nEncodings) break;
  262. +       
  263. +       printf("\n  Invalid encoding selected");
  264. +     }
  265. +   encoding_atom = XInternAtom(dpy,"XV_ENCODING",False);
  266. +   XvSelectPortNotify(dpy, port, True);
  267. +   XvSetPortAttribute(dpy, port, encoding_atom, encoding);
  268. +   while (1)
  269. +     {
  270. +       XNextEvent(dpy, &event);
  271. +       if (event.type == evb + XvPortNotify)
  272. +     {
  273. +       pe = (XvEvent *)&event;
  274. +       
  275. +       if (pe->xvport.attribute == encoding_atom)
  276. +         {
  277. +           printf("\n  Port encoding changed to %s\n", encoding_name);
  278. +         }
  279. +       else
  280. +         printf("          Got unexpected port notify event\n");
  281. +       break;
  282. +     }
  283. +     }
  284. + }
  285. + Setup(argc, argv, nAdaptors, pAdaptors, p_port, p_depth, p_vis_id)
  286. +      int         argc;
  287. +      char        *argv[];
  288. +      unsigned long nAdaptors;
  289. +      XvAdaptorInfo *pAdaptors;
  290. +      unsigned long *p_port;
  291. +      unsigned long *p_depth;
  292. +      unsigned long *p_vis_id;
  293. + {
  294. +   int ii, jj;
  295. +   XvAdaptorInfo *pAdaptor;
  296. +   XvFormat *pFormat;
  297. +   int adaptor, port, depth, visual_id;
  298. +   adaptor = port = depth = visual_id = -1;
  299. +   /* LOOK THROUGH COMMAND LINE ARGUMENTS */
  300. +   for ( ii = 1; ii < argc; ii++ )
  301. +     {
  302. +       if (strcmp( argv[ii], "-adaptor") == 0)
  303. +     {
  304. +         if(++ii < argc)
  305. +           adaptor = atoi(argv[ii]);
  306. +             else
  307. +           UseMsg(argv);
  308. +     }
  309. +       else if (strcmp( argv[ii], "-port") == 0)
  310. +     {
  311. +         if(++ii < argc)
  312. +           port = atoi(argv[ii]);
  313. +             else
  314. +           UseMsg(argv);
  315. +     }
  316. +       else if (strcmp( argv[ii], "-depth") == 0)
  317. +     {
  318. +         if(++ii < argc)
  319. +           depth = atoi(argv[ii]);
  320. +             else
  321. +           UseMsg(argv);
  322. +     }
  323. +       else if (strcmp( argv[ii], "-visual") == 0)
  324. +     {
  325. +         if(++ii < argc)
  326. +           visual_id = atoi(argv[ii]);
  327. +             else
  328. +           UseMsg(argv);
  329. +     }
  330. +       else if (strcmp( argv[ii], "-help") == 0)
  331. +     {
  332. +       UseMsg(argv);
  333. +     }
  334. +     }
  335. +   if (adaptor < 0)
  336. +     {
  337. +       pAdaptor = pAdaptors;
  338. +     }
  339. +   else
  340. +     {
  341. +       if (adaptor > nAdaptors)
  342. +     {
  343. +       printf("\n  Adaptor #%d doesn't exist.\n", adaptor);
  344. +       return False;
  345. +     }
  346. +       pAdaptor = pAdaptors+(adaptor-1);
  347. +     }
  348. +   if (port < 0)
  349. +     {
  350. +       port = pAdaptor->base_id;
  351. +     }
  352. +   else
  353. +     {
  354. +       if (port > pAdaptor->num_ports)
  355. +     {
  356. +       printf("\n  Port #%d doesn't exist for adaptor #%d.\n", 
  357. +          port, adaptor);
  358. +       return False;
  359. +     }
  360. +     }
  361. +   pFormat = pAdaptor->formats;
  362. +   if (depth < 0)
  363. +     {
  364. +       depth = pFormat->depth;
  365. +     }
  366. +   else
  367. +     {
  368. +       for (ii=0; ii<pAdaptor->num_formats; ii++)
  369. +     {
  370. +       if (pFormat->depth == depth) break;
  371. +       pFormat++;
  372. +     }
  373. +       if (ii >= pAdaptor->num_formats)
  374. +     {
  375. +       printf("\n  Depth %d not supported by adaptor.\n", depth);
  376. +       return False;
  377. +     }
  378. +     }
  379. +   if (visual_id < 0)
  380. +     {
  381. +       visual_id = pFormat->visual_id;
  382. +     }
  383. +   else
  384. +     {
  385. +       pFormat = pAdaptor->formats;
  386. +       for (ii=0; ii<pAdaptor->num_formats; ii++)
  387. +     {
  388. +       if ((pFormat->visual_id == visual_id) && pFormat->depth == depth)
  389. +         break;
  390. +       pFormat++;
  391. +     }
  392. +       if (ii >= pAdaptor->num_formats)
  393. +     {
  394. +       printf("\n  Visual-id %d at depth %d not supported by adaptor.\n", 
  395. +          depth, visual_id);
  396. +       return False;
  397. +     }
  398. +     }
  399. +   *p_port = port;
  400. +   *p_depth = depth;
  401. +   *p_vis_id = visual_id;
  402. +   return True;
  403. + }
  404. + UseMsg(argv)
  405. +      char        *argv[];
  406. + {
  407. +   printf("use: %s [option]\n", argv[0]);
  408. +   printf("\t-adaptor #                       adaptor number\n");
  409. +   printf("\t-port #                          port (XID)\n");
  410. +   printf("\t-depth #                         drawable depth (planes)\n");
  411. +   printf("\t-visual #                        drawable visual (id)\n");
  412. +   exit();
  413. + }
  414.  
  415. -- 
  416. --
  417. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  418. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  419. Sunnyvale, California 94086            at&t: 408/522-9236
  420.